package kr.hkit.androidcomplete01.ch08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public class HandlerOrder extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View vw = new MyView(this);
		vw.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction()==MotionEvent.ACTION_DOWN){
					Log.d("HandlerOrder", "1 순위 Listener" + event.getX() + ","+event.getY());
//				return true;
//true가 활성화 되면 2,3순위는 실행이 안된다..						
				}
				return false;
			}
		});
		setContentView(vw);
	}
	
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		super.onTouchEvent(event);
		if(event.getAction()==MotionEvent.ACTION_DOWN){
			Log.d("HandlerOrder", "3 순위 Activity callback" + event.getX() + ","+event.getY());
		return true;
		}			
		return false;
	}		
	


	class MyView extends View{

		public MyView(Context context) {
			super(context);
		}

		@Override
		public boolean onTouchEvent(MotionEvent event) {
			super.onTouchEvent(event);
			if(event.getAction()==MotionEvent.ACTION_DOWN){
				Log.d("HandlerOrder", "2 순위 View callback" + event.getX() + ","+event.getY());
			return true;
			}			
			return false;
		}
		
		
		
	}
}
